<?php
namespace DinhThi\MVC;
class Configuration {
    /**
     * @var Properties $property
     */
    private $property;
    private static $instance = null;

    private function __construct(){

    }

    /**
     * Load configuration file
     * @param $filename string
     */
    public function load($filename){
        $this->property = Properties::getInstance();
        $this->property->load($filename);
    }

    /**
     * Set config
     * @param $name Key
     * @param $value Key value
     */
    public function setProperty($name, $value){
        $this->property->setProperty($name, $value);
    }
    /**
     * Get config value
     * @param $name Key
     * @param string $defaultValue Return value when key not found
     * @return mixed
     */
    public function getProperty($name, $defaultValue = ''){
        if ($this->property->getProperty($name) != null){
            return $this->property->getProperty($name);
        }
        return $defaultValue;
    }


    /**
     * Get singleton class
     * @return Configuration
     */
    public static function getInstance(){
        if (Configuration::$instance == null){
            Configuration::$instance = new Configuration();
        }
        return Configuration::$instance;
    }


}